package com.medata.utils;

import com.medata.dataObject.Category;
import com.medata.dataObject.Templatefields;
import com.medata.service.impl.CategoryServiceImpl;
import com.medata.service.impl.TemplatefieldsServiceImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：zb
 * @date ：Created in 2019/5/14 0014 15:20
 * @description：
 */

public class MapUrlUtil {
    public static Map<String,String> getUrls(TemplatefieldsServiceImpl templatefieldsService, CategoryServiceImpl categoryService, List<Templatefields> templatefieldsList, Integer dbid){
        Map<String,String> map=new HashMap<>();
        for (Templatefields templatefields:templatefieldsList){
            if (templatefields.getRefId()!=0){
                List<Templatefields> templ = templatefieldsService.findByRefId(templatefields.getRefId());
                for (Templatefields tp:templ){
                    Category category = categoryService.findByDbid(tp.getDbid());
                    map.put("/editor/zlpost/"+tp.getDbid(),category.getDc());
                }
            }
        }
        map.remove("/editor/zlpost/"+String.valueOf(dbid));
        return map;
    }

}
